﻿@namespace AntDesign
@inherits AntDomComponentBase
@typeparam TModel
@using Microsoft.AspNetCore.Components.Forms;
@using AntDesign.Internal;

<Spin Spinning="Loading" WrapperClassName="ant-form-spin-wrapper">
    <EditForm class="@ClassMapper.Class"
              style="@Style"
              id="@Id"
              method="@Method"
              FormName="@Name"
              Enhance="@Enhance"
              autocomplete="@Autocomplete"
              EditContext="_editContext"
              OnValidSubmit="OnValidSubmit"
              OnInvalidSubmit="OnInvalidSubmit">
        @if (UseRulesValidator)
        {
            <FormRulesValidator @ref="_rulesValidator" />
        }
        else if (Validate != null)
        {
            @Validator
        }
        else
        {
            <DataAnnotationsValidator />
        }
        <CascadingValue Value="this" Name="Form" TValue="IForm" IsFixed="@true">
            @if (Size.HasValue)
            {
                <CascadingValue Value="Size" Name="FormSize">
                    @ChildContent(Model)
                </CascadingValue>
            }
            else
            {
                @ChildContent(Model)
            }
        </CascadingValue>
    </EditForm>
</Spin>